<?
$role = $_SESSION['current_role'];

if ($USE_FIXED_MENU) {
	include $MODULE."_role_$role.php";
} else {
		//find menus belongs to the current role
		$current_role = $_SESSION['current_role'];
		$rm = pg_query("SELECT * FROM role_menus WHERE role_name='$current_role'");
		if (pg_numrows($rm)==1) {
			$d = pg_fetch_object($rm,0);
			$curr_role_menus = $d->menus;
		}else{
			$curr_role_menus = '';
		}
		$curr_role_menus = preg_replace("/{|}/","",$curr_role_menus);
		$curr_role_menus = split(",",$curr_role_menus);
		//print_r($role_menus);exit;

		//find all menus
		$all_menus = pg_query("SELECT * FROM menus ORDER BY sort");

?>

<table border="0" cellpadding="3" cellspacing="0" style="width:220px;" class="tableMainBodyFont">
    <?
	$bil = 0;
    while ($menu = pg_fetch_object($all_menus)) {
		if (!in_array($menu->id,$curr_role_menus)) continue;
		else {
		// onmouseover="this.className='tablenavigationTDRollover';this.style.cursor = 'hand'" onmouseout="this.className='tablenavigationTD';"
			$hover = "onmouseover=\"this.className='tablenavigationTDRollover';this.style.cursor = 'hand'\" onmouseout=\"this.className='tablenavigationTD';\"";
			$link = "<a href=\"$menu->url\" class=\"fontnavigation\">$menu->caption</a>";
			if ($menu->is_parent == 't') {
				$hover = "";
				$link = "$menu->caption";
			}
		}
    ?>
    <tr align="center" id="<?="row_$i"?>">
      <td align="left" style=" padding-left:5px;" class="<? echo ($menu->is_parent=='t')?"tablenavigationHeader":"tablenavigationTD";?>" <?=$hover?>><?=$link?></td>
    </tr>
    <?
	  }
	  ?>
  </table>
<? } ?>